package demo1;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 苏李涛
 * Date: 2024-05-17
 * Time: 19:01
 */
public class Dog extends Animal {


    public Dog(String name, int age) {
        super(name, age);
    }

    public void voice() {
        System.out.println(name+ " 正在汪汪叫");
    }






   /* public static void func(Animal animal) {
   2.方法的传参
        animal.voice();
    }*/

    /*public static Animal func1() {
    3.方法的返回值
        Dog dog = new Dog("wangcai", 4);
        return dog;
    }*/

    @Override
    public void eat() {
        System.out.println( name + "正在吃狗粮");

    }

    public static void func(Animal animal) {
        animal.eat();
    }

    public static void main(String[] args) {
        Dog dog = new Dog("wangcai", 2);
        func(dog);

        System.out.println("================");
        cat cat = new cat("mimi", 2);
        func(cat);





        //向上转型
        //1.直接赋值
        /*Animal animal = new Dog("wangcai", 2);


        Dog dog = new Dog("wangcai", 4);
        //2.方法的传参
        func(dog);

        //3.方法的返回值
        Animal animal2 = func1();
        System.out.println(animal2);*/
    }
}
